﻿using MediatR;
using RedDragon.Common.Domain.warehouse;
using RedDragon.Common.Infrastructure.Interface;
using T.Common.Domain.Common;

namespace RedDragon.RBAC.API.Application.Common.Inventoryscheduling
{
    public class TargetWareHouseFullHandler : IRequestHandler<TargetWareHouseFullCommon, Result>
    {
        public readonly IBaseRepository<Warehouse> WarehouseRepository;

        public TargetWareHouseFullHandler(IBaseRepository<Warehouse> warehouseRepository)
        {
            WarehouseRepository = warehouseRepository;
        }

        public async Task<Result> Handle(TargetWareHouseFullCommon request, CancellationToken cancellationToken)
        {
            var result = new Result() { Code = 0, Msg = "" };
            try
            {
                var list = WarehouseRepository.Query().Where(x => x.WarehouseId == request.Id);
                result.Data = list;
            }
            catch (Exception)
            {

                throw;
            }
            return result;
        }
    }
}
